Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort ITIS response & multiple common names #237

Merged
merged 28 commits into from
May 10, 2024
Merged

Conversation

mauberti-bc
Copy link
Collaborator

@mauberti-bc mauberti-bc commented Mar 5, 2024

Links to Jira Tickets

N/A

Description of Changes

  • Sort the ITIS search response to prioritize exact matches
  • Allow for multiple common names, rather than taking only the first common name from ITIS

Testing Notes

@mauberti-bc mauberti-bc added the Early Feedback Welcome PR is not finished, but early review feedback is welcomed label Mar 5, 2024
@codecov-commenter
Copy link

codecov-commenter commented Mar 5, 2024

Codecov Report

Attention: Patch coverage is 89.13043% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 68.64%. Comparing base (dd73aa0) to head (1dddfa5).

Files Patch % Lines
api/src/services/taxonomy-service.ts 40.00% 1 Missing and 2 partials ⚠️
api/src/services/itis-service.ts 75.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #237      +/-   ##
==========================================
+ Coverage   68.45%   68.64%   +0.19%     
==========================================
  Files         193      194       +1     
  Lines        4758     4794      +36     
  Branches      630      637       +7     
==========================================
+ Hits         3257     3291      +34     
  Misses       1369     1369              
- Partials      132      134       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

api/src/repositories/taxonomy-repository.ts Outdated Show resolved Hide resolved
api/src/services/itis-service.ts Outdated Show resolved Hide resolved
api/src/services/taxonomy-service.ts Outdated Show resolved Hide resolved
api/src/services/taxonomy-service.ts Outdated Show resolved Hide resolved
api/src/services/taxonomy-service.ts Outdated Show resolved Hide resolved
api/src/utils/itis-sort.test.ts Outdated Show resolved Hide resolved
api/src/utils/itis-sort.ts Show resolved Hide resolved
api/src/utils/itis-sort.ts Outdated Show resolved Hide resolved
api/src/utils/itis-sort.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@MacQSL MacQSL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the Solr query can be optimized to get around some of the sorting / filtering on exact matches.
Note: vernacular terms (common names) are "$" delimited.

Heres a simplified query for only the common names portion

q=vernacular:$black\%20bear$*+vernacular:$*black\%20bear$*

  1. This will search for a common name exact match first ie: "$Black bear$"
  2. Then searches for any common name ending with "black bear" ie: "$American black bear$"

Still working on the scientific name portion of this query. But this is what I have so far.
You can create a postman variable for the {{SPECIES}} refs.

https://services.itis.gov/?wt=json&fl=tsn+scientificName:nameWOInd+kingdom+parentTSN+commonNames:vernacular+updateDate+usage+rank&q=((vernacular:${{SPECIES}}$*+vernacular:$*{{SPECIES}}$*)+AND+usage:/(valid|accepted)/)+((nameWOInd:{{SPECIES}}+nameWOInd:*{{SPECIES}})+AND+usage:/(valid|accepted)/)

I'll update this comment with the revised query tomorrow.

@mauberti-bc
Copy link
Collaborator Author

mauberti-bc commented Mar 7, 2024

I think the Solr query can be optimized to get around some of the sorting / filtering on exact matches. Note: vernacular terms (common names) are "$" delimited.

@MacQSL True. I tried adjusting the query to remove the need for sorting but couldn't consistently get the same results as the sorting functions here, and I figured that the sorting functions in this PR work well enough for now. The query can be optimized down the road

Copy link

sonarqubecloud bot commented Mar 7, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
11.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

NickPhura
NickPhura previously approved these changes May 10, 2024
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
9.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@NickPhura NickPhura merged commit c8527c0 into dev May 10, 2024
18 of 19 checks passed
@NickPhura NickPhura deleted the search-adjustments branch May 10, 2024 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Early Feedback Welcome PR is not finished, but early review feedback is welcomed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants